# coding: utf-8


import os
import numpy as np
from PIL import Image
import binascii
import time
import shutil


NORMAL_EXE_PATH = '../software/normal'
MALWARE_EXE_PATH = '../software/malware'


def clear_exe():

    with open('../exe_rm.txt', 'w') as f:
        
        # 处理良性软件
        files = os.listdir(NORMAL_EXE_PATH)
        for file in files:
            exe_file = os.path.join(NORMAL_EXE_PATH, file)
            file_size = os.path.getsize(exe_file)  # 字节数
            if file_size < 1024:  # 过滤掉小于 1 KB 的文件
                f.write(file + '\n')
            elif file_size > 5 * 1024 * 1024:  # 过滤掉大于 5 MB 的文件
                f.write(file + '\n')
            else:
                continue

        # 处理恶意软件
        files = os.listdir(MALWARE_EXE_PATH)
        for file in files:
            exe_file = os.path.join(MALWARE_EXE_PATH, file)
            file_size = os.path.getsize(exe_file)  # 字节数
            if file_size < 500:  # 过滤掉小于 500 B 的文件
                f.write(file + '\n')
            elif file_size > 2 * 1024 * 1024:  # 过滤掉大于 2 MB 的文件
                f.write(file + '\n')
            else:
                continue


if __name__ == '__main__':
    clear_exe()